package com.chinacoal.microservice.controller;

import com.chinacoal.microservice.TenantManagementClient;
import com.chinacoal.microservice.pojo.CcmsSmartleasingTenant;
import com.chinacoal.microservice.service.TenantManagementService;
import com.chinacoal.microservice.util.PassToken;
import com.chinacoal.microservice.util.QueryCriteria;
import com.chinacoal.microservice.util.Result;
import com.chinacoal.microservice.util.UserLoginToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhuliang
 * @version V1.0
 * @Description: 运维模块-租户管理-后端控制类
 * @date 2020-11-18 14：34
 */
@RestController
public class TenantManagementController implements TenantManagementClient {

    @Autowired
    private TenantManagementService tenantManagementService;

    /**
     * @Description: 查询所有的租户信息（带分页）
     * @author zhuliang
     * @date 2020/11/18 14:39
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingTenant>> getAllTenant(QueryCriteria queryCriteria, String token) {
        return tenantManagementService.getAllTenant(queryCriteria, token);
    }

    /**
     * @Description: 根据租户id查询对应的租户信息
     * @author zhuliang
     * @date 2020/11/18 17:15
     */
    @Override
    @UserLoginToken
    public Result<CcmsSmartleasingTenant> getTenantById(String pkTenantId, String token) {
        return tenantManagementService.getTenantById(pkTenantId, token);
    }

    /**
     * @Description: 修改租户信息
     * @author zhuliang
     * @date 2020/11/18 17:19
     */
    @Override
    @UserLoginToken
    public Result updateTenant(CcmsSmartleasingTenant tenant, String token) {
        return tenantManagementService.updateTenant(tenant, token);
    }

    /**
     * @Description: 批量删除租户信息
     * @author zhuliang
     * @date 2020/11/18 17:28
     */
    @Override
    @UserLoginToken
    public Result deleteTenant(String deleteId, String token) {
        return tenantManagementService.deleteTenant(deleteId, token);
    }

    /**
     * @Description: 条件查询租户信息（带分页）
     * @author zhuliang
     * @date 2020/11/18 17:42
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingTenant>> getAllTenantByCondition(QueryCriteria queryCriteria, String token) {
        return tenantManagementService.getAllTenantByCondition(queryCriteria, token);
    }

    /**
     * @Description: 重置租户密码
     * @author zhuliang
     * @date 2021/1/7 18:59
     */
    @Override
    @UserLoginToken
    public Result resetPassword(String pkTenantId, String contactPhone, String token) {
        return tenantManagementService.resetPassword(pkTenantId, contactPhone, token);
    }
}
